package com.xulinhao.educms.controller;/**
 * @author xulinhao
 * @create 2021-09-04 22:09
 */

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xulinhao.commonutils.R;
import com.xulinhao.educms.entity.CrmBanner;
import com.xulinhao.educms.service.CrmBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author xlh
 * @packagename: com.xulinhao.educms.controller
 * @classname: BannerFrontController
 * @Description:
 * @Date 2021/9/4
 */
@RestController
@RequestMapping("/educms/bannerfront")
@CrossOrigin
public class BannerFrontController {
    @Autowired
    private CrmBannerService bannerService;

    //查询所有banner
    @GetMapping("getAllBanner")
    public R getAllBanner(){
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        wrapper.last("limit 2");
        List<CrmBanner> list =bannerService.selectAllBanner();
        return R.ok().data("list", list);
    }
}
